home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 21
/
Aminet 21 (1997)(GTI - Schatztruhe)[!][Oct 1997].iso
/
Aminet
/
util
/
cdity
/
availmem2.lha
/
AvailMem2
/
src
/
AvailMem2_CX.s
< prev
next >
Wrap
Text File
|
1997-07-01
|
10KB
|
392 lines
machine 68020
* program includes
include "AvailMem2.i"
include "AvailMem2_gui.i"
include "lvo.i"
incdir "include:"
include "exec/types.i"
include "libraries/commodities.i"
include "exec/funcdef.i"
* program exports
CX_POPKEY equ 1 ;CX GUI Popup key
section code,code ;availmem code section
_HandleCxMsgs
* * * * * * * * * * * * * * * * * * * * *
* *
* Handles all CX messages. *
* *
* * * * * * * * * * * * * * * * * * * * *
movem.l d0-a6,-(sp) ;push all registers
.MsgLoop_CxPort
move.l (4).w,a6 ;put execbase in a6
move.l ptr_CxPort,a0 ;get cxport
jsr _LVOGetMsg(a6) ;get any waiting message
move.l d0,ptr_TempMsg ;store msg
beq .no_CxPortMessages ;if no message, continue looping
move.l _CommoditiesBase,a6 ;put commoditesbase in a6
move.l ptr_TempMsg,a4 ;put msg in a4
move.l a4,a0 ;put msg in a0
jsr _LVOCxMsgID(a6) ;get MsgID
move.l d0,d5 ;put MsgID in d5
move.l a4,a0 ;put msg in a0
jsr _LVOCxMsgType(a6) ;get MsgID
move.l d0,d6 ;put MsgType in d6
cmp.l #CXM_IEVENT,d6 ;check if program event
bne .no_CXM_IEVENT ;skip if not
cmp.l #CX_POPKEY,d5 ;check if popup-key was pressed
bne .no_CX_POPKEY ;skip if not
tst.l MemoryDisplayWnd ;check if window open
beq .Open_MemoryDisplayWnd_HotKey ;skip if already open
move.l _IntuitionBase,a6 ;put intuitionbase in a6
move.l MemoryDisplayWnd,a0 ;put ptr to mem-display window in a0
jsr _LVOActivateWindow(a6) ;activate memory-display window
move.l MemoryDisplayWnd,a0 ;put ptr to mem-display window in a0
jsr _LVOWindowToFront(a6) ;bring window to front
bra .no_CX_POPKEY ;skip window opening
.Open_MemoryDisplayWnd_HotKey
tst.l ResizeWnd
bne .no_CX_POPKEY
jsr _OpenGUI ;open program GUI
tst.l d0 ;check if open succeded
beq .Fail ;bail out if error
clr.l d5 ;reset MsgID
.no_CX_POPKEY
clr.l d6
.no_CXM_IEVENT
cmp.l #CXM_COMMAND,d6 ;Check if commodity event
bne .no_CXM_COMMAND ;skip if not
* check for Cx events
cmp.l #CXCMD_ENABLE,d5 ;check if Enable command sent
bne .no_CXCMD_ENABLE ;skip if not
move.l ptr_ProgramBroker,a0 ;put program broker in a0
moveq.l #TRUE,d0 ;set active to true
jsr _LVOActivateCxObj(a6) ;activate main broker
.no_CXCMD_ENABLE
cmp.l #CXCMD_DISABLE,d5 ;check if Disable command sent
bne .no_CXCMD_DISABLE ;skip if not
move.l ptr_ProgramBroker,a0 ;put program broker in a0
moveq.l #FALSE,d0 ;set active to false
jsr _LVOActivateCxObj(a6) ;deactivate main broker
.no_CXCMD_DISABLE
cmp.l #CXCMD_UNIQUE,d5 ;check if Unique command sent
beq .AppearUnique ;goto if true
cmp.l #CXCMD_APPEAR,d5 ;check if Appear command sent
bne .no_CXCMD_APPEAR ;skip if not
.AppearUnique
tst.l MemoryDisplayWnd ;check if window open
beq .Open_MemoryDisplayWnd ;skip if already open
move.l _IntuitionBase,a6 ;put intuitionbase in a6
move.l MemoryDisplayWnd,a0 ;put ptr to mem-display window in a0
jsr _LVOActivateWindow(a6) ;activate memory-display window
move.l MemoryDisplayWnd,a0 ;put ptr to mem-display window in a0
jsr _LVOWindowToFront(a6) ;bring window to front
bra .no_CXCMD_APPEAR ;skip window opening
.Open_MemoryDisplayWnd
tst.l ResizeWnd
bne .no_CXCMD_APPEAR
jsr _OpenGUI ;open program GUI
tst.l d0 ;check if open succeded
beq .Fail ;bail out if error
clr.l d5 ;reset MsgID
.no_CXCMD_APPEAR
cmp.l #CXCMD_DISAPPEAR,d5 ;check if Disappear command sent
bne .no_CXCMD_DISAPPEAR ;skip if not
jsr _CloseGUI ;close program GUI
clr.l d5 ;reset MsgID
.no_CXCMD_DISAPPEAR
cmp.l #CXCMD_KILL,d5 ;check if kill-command sent
bne .no_CXCMD_KILL
st.l prg_Terminate ;enable program termination
clr.l d5 ;reset MsgID
.no_CXCMD_KILL
clr.l d6 ;reset MsgType
.no_CXM_COMMAND
move.l (4).w,a6 ;put execbase in a6
move.l ptr_TempMsg,a1 ;put tempmsg in a1
jsr _LVOReplyMsg(a6) ;reply cx msg
bra .MsgLoop_CxPort ;loop message-reader
.no_CxPortMessages
movem.l (sp)+,d0-a6 ;pop all registers
clr.l d0 ;set exitcode to FALSE
rts ;return
.Fail
movem.l (sp)+,d0-a6 ;pop all registers
st.l d0 ;set exitcode to TRUE
rts ;return
_FlushPort
* * * * * * * * * * * * * * * * * * * * *
* *
* Flushes the specified port from any *
* waiting messages. *
* *
* IN: a0 - ptr to msgport. *
* *
* * * * * * * * * * * * * * * * * * * * *
movem.l d0-a6,-(sp) ;push all registers
move.l (4).w,a6 ;put execbase in a6
move.l a0,a3 ;put msg-port in a3
.MsgLoop
move.l a3,a0 ;put msg-port in a0
jsr _LVOGetMsg(a6) ;get msg waiting
tst.l d0 ;check for waiting msg
beq .NoMsgsLeft ;skip if no more msgs
move.l d0,a1 ;put msg in a1
jsr _LVOReplyMsg(a6) ;reply whatever msg
.NoMsgsLeft
movem.l (sp)+,d0-a6 ;pop all registers
rts ;return
_AttachCXFilter
* * * * * * * * * * * * * * * * * * * * *
* *
* Attaches a CX Hotkey to the program *
* CX chain. *
* *
* IN: a0 - ptr to hotkey combination. *
* d0 - Event. *
* *
* OUT: d0 - success. *
* *
* * * * * * * * * * * * * * * * * * * * *
movem.l d0-a6,-(sp) ;push all registers
movea.l a0,a5 ;put hotkey in a5
move.l d0,d7 ;put event in d7
movea.l a5,a0 ;put hotkey in a0
movea.l _CommoditiesBase,a6 ;put commoditiesbase in a6
moveq #CX_FILTER,d0 ;put CX_FILTER in d0
suba.l a1,a1 ;no 2nd argument
jsr _LVOCreateCxObj(a6) ;create a filter
movea.l d0,a3 ;store filter in a3
move.l a3,d0 ;check if successfull
beq.s .Fail ;bail out if failure
movea.l ptr_ProgramBroker,a0 ;put broker in a0
movea.l a3,a1 ;put filter in a1
jsr _LVOAttachCxObj(a6) ;attach filter to broker
move.l ptr_CxPort,d0 ;put cx-port in d0
movea.l d0,a0 ;put cx-port in a0
movea.l d7,a1 ;put even in a1
moveq #CX_SEND,d0 ;put CX_SEND in d0
jsr _LVOCreateCxObj(a6) ;create sender
movea.l d0,a2 ;store sender in a2
move.l a2,d0 ;check if successfull
beq.s .Fail ;bail out if failure
movea.l a3,a0 ;put filter in a0
movea.l a2,a1 ;put sender in a1
jsr _LVOAttachCxObj(a6) ;attach sender to filter
moveq #CX_TRANSLATE,d0 ;put CX_TRANSLATE in d0
suba.l a0,a0 ;no 1st argument
suba.l a1,a1 ;no 2nd argument
jsr _LVOCreateCxObj(a6) ;create translator
tst.l d0 ;check if successfull
beq.s .Fail ;bail out if failure
movea.l d0,a1 ;put translator in a1
movea.l a3,a0 ;put filter in a0
jsr _LVOAttachCxObj(a6) ;attach translator to filter
movea.l a3,a0 ;put filter in a0
jsr _LVOCxObjError(a6) ;get Cx-filter errors
tst.l d0 ;check for ANY errors
bne.s .Fail ;bail out if found any
movem.l (sp)+,d0-a6 ;pop all registers
st.l d0 ;set exitcode to TRUE
rts ;return
.Fail
movem.l (sp)+,d0-a6 ;pop all registers
clr.l d0 ;set exitcode to FALSE
rts ;return
_SetupCX
* * * * * * * * * * * * * * * * * * * * *
* *
* Adds the program as a Cx-broker to *
* the Cx-chain. *
* *
* OUT: d0 - success. (=0 FAIL) *
* *
* * * * * * * * * * * * * * * * * * * * *
movem.l d1-a6,-(sp) ;push all registers
jsr _QuitCX ;remove old CX (if any)
move.l (4).w,a6 ;put execbase in a6
jsr _LVOCreateMsgPort(a6) ;create a msg-port
move.l d0,ptr_CxPort ;store CX msg-port
beq .Fail ;bail out if failure
move.l _CommoditiesBase,a6 ;put commoditiesbase in a6
lea.l prg_CxNewBroker,a0 ;put ptr to NewBroker in a0
move.l ptr_ConfigName,2(a0) ;set handler name
jsr _LVOCxBroker(a6) ;create program broker
move.l d0,ptr_ProgramBroker ;store program broker
beq .Fail ;bail out if failure
move.l ptr_PopupKey,a0 ;get ptr to popup key
move.l #CX_POPKEY,d0 ;set event to popup key
jsr _AttachCXFilter ;attach hotkey
tst.l d0 ;check if attachment succeeded
beq .Fail ;bail out if failure
movem.l (sp)+,d1-a6 ;pop all registers
st.l d0 ;return TRUE
rts ;return
.Fail
movem.l (sp)+,d1-a6 ;pop all registers
clr.l d0 ;return FALSE
rts ;return
_QuitCX
* * * * * * * * * * * * * * * * * * * * *
* *
* Removes the program Cx-broker from *
* the Cx-chain. *
* *
* * * * * * * * * * * * * * * * * * * * *
movem.l d0-a6,-(sp) ;push all registers
tst.l ptr_ProgramBroker ;check if Broker installed
beq .NoCXInstalled ;skip if not installed
move.l _CommoditiesBase,a6 ;put commoditesbase in a6
move.l ptr_ProgramBroker,a0 ;put program broker in a0
jsr _LVODeleteCxObjAll(a6) ;delete all Cx-objects
clr.l ptr_ProgramBroker ;reset ptr to broker
.NoCXInstalled
tst.l ptr_CxPort ;check if msg-port installed
beq .NoMsgPortActive ;skip if not installed
move.l ptr_CxPort,a0 ;put ptr to port in a0
jsr _FlushPort ;flush the port from all messages
move.l (4).w,a6 ;put execbase in a6
jsr _LVODeleteMsgPort(a6) ;delete the msg-port
clr.l ptr_CxPort ;reset ptr to port
.NoMsgPortActive
movem.l (sp)+,d0-a6 ;pop all registers
rts ;return
section data,data ;availmem data section
* CX strings
_ProgramTitle dc.b "AvailMem2 © 1996-97 Jesper Svennevid",0
_ProgramDescr dc.b "Displays your memory! :)",0
_DefaultPopup dc.b "control lalt a",0
cnop 0,8
* CX NewBroker
prg_CxNewBroker
dc.b NB_VERSION ;version
dc.b 0 ;Reserve1
dc.l 0 ;Handler name
dc.l _ProgramTitle ;Title
dc.l _ProgramDescr ;Description
dc.w NBU_NOTIFY!NBU_UNIQUE ;Unique
dc.w COF_SHOW_HIDE ;Flags
prg_CxPri
dc.b 0 ;Pri
dc.b 0 ;Reserve2
ptr_CxPort
dc.l 0 ;BrokerPort
dc.w 0 ;Reserved channel
section bss,bss ;availmem bss section
* program variables
ptr_ProgramBroker ds.l 1 ;ptr to program CX-broker
ptr_PopupKey ds.l 1 ;ptr to program popup key
prg_Popup ds.l 1 ;program start-popup variable